/**
 * <p>Copyright (R) 2014 正方软件股份有限公司。<p>
 */
package com.zfsoft.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(path="hi")
public class HelloController {
	
	private static final Logger log = LoggerFactory.getLogger(HelloController.class);
	
	@Autowired
	private TempFileBuilder workFileBuilder;
	
	@ResponseBody
	@RequestMapping(path="hi_name")
	public String hi_name(String username,HttpServletRequest request,Model model) {
		model//
		.addAttribute("name", "age")//
		.addAttribute("name", "weiguangyue");
		
		String name = request.getParameter("username");
		return username+"";
	}
	
	@ResponseBody
	@RequestMapping(path="hi_array")
	public String hi_array(String[] names) {
		StringBuilder sb = new StringBuilder();
		if(names != null) {
			for(String s : names) {
				sb.append(s).append(",");
			}
		}
		return sb.toString();
	}
	
	//org.springframework.beans.propertyeditors.StringArrayPropertyEditor
	@ResponseBody
	@RequestMapping(path="hi_list")
	public String hi_array(List<String> names) {
		StringBuilder sb = new StringBuilder();
		if(names != null) {
			for(String s : names) {
				sb.append(s).append(",");
			}
		}
		return sb.toString();
	}
	
	@ResponseBody
	@RequestMapping(path="hi_map")
	public String hi_array(Map<String,String> names) {
		StringBuilder sb = new StringBuilder();
		return sb.toString();
	}
}
